#pragma once

#include "Containers/String.h"
#include "Path/Path.h"
#include "FileUtils.m.h"

RSTRUCT()
struct WHENGINE_API SFileUtils 
{
public:    
    ROBJECT

    RFUNCTION()
    static CString ReadToString(const SPath & FilePath);

    static TVector<uint8_t> ReadToBinary(const SPath &InFilePath,int64_t MaxSize = -1);

    RFUNCTION()
    static void SaveTo(const CString & FileContent, const SPath & FilePath);

    static void SaveBinaryTo(const TVector<uint8_t> & FileContent, const SPath & FilePath);

    //return error message
    static CString RenameFileOrDirectory(const SPath & OldDirectory, const CString& NewDirectoryName);

    static CString DeleteFile(const SPath & FilePath);

    //return error message
    static CString CreateDirectory(const SPath & DirectoryPath);
    static CString DeleteDirectory(const SPath & DirectoryPath);
    //删除目录下的所有文件和子目录
    static CString ClearDirectory(const SPath & DirectoryPath);

    static void CopyDirectory(const SPath & SourceDirectory
        , const SPath & TargetDirectory
        ,bool bRecursive = true
        ,bool bOverwrite = true);

    static std::filesystem::file_time_type  
    GetLastWriteTime(const SPath & FilePath);

    //copy file, will overwrite if destination file already exists
    RFUNCTION()
    static bool CopyFile(const SPath & Source, const SPath & Destination);

}; 